package com.neural.neighbourhood;

import java.util.ArrayList;
import java.util.List;

import com.neural.descriptor.Point;
import com.neural.descriptor.SizeDescriptor;

public class DiamondNeighbourhood extends Neighbourhood {

	public DiamondNeighbourhood() {
		super("diamond");
	}

	@Override
	public List<Point> getPointsFor(Point point, SizeDescriptor size, Integer neighbourSize) {

		List<Point> points = new ArrayList<Point>(neighbourSize * 10);
		for (int i = -neighbourSize, blocks = 1, y = 0; i <= 0; i++, y--, blocks -= 2) {
			for(int j = y; j < y+blocks; j++) {
				addIfCan(points, point, size, i, j);
			}
		}
		points.remove(point);
		for (int i = neighbourSize, blocks = 1, y = 0; i > 0; i--, y--, blocks += 2) {
			for(int j = y; j < y+blocks; j++) {
				addIfCan(points, point, size, i, j);
			}
		}
		
		return points;
	}
}
